/*
 * @Author: 13558093597 277098906@qq.com
 * @Date: 2025-06-13 16:37:28
 * @LastEditors: 13558093597 277098906@qq.com
 * @LastEditTime: 2025-06-30 16:39:12
 * @FilePath: \mes_app\lib\components\home\storage.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import 'package:flutter/material.dart';
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:mes_app/color/hex.dart';
import 'package:mes_app/extensions/ex_widget.dart';
import 'package:mes_app/utils/styles.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

///
/// 出入库
///
class HomeInOutStorageController extends GetxController {}

class HomeInOutStorageView extends GetView<HomeInOutStorageController> {
  const HomeInOutStorageView({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: HexColor(HexColor.colorF9f9),
      appBar: TDNavBar(
        title: '出入库管理',
        titleColor: HexColor(HexColor.color0000),
        titleFontWeight: FontWeight.w700,
        titleFont: Font(size: StylesUtils.fontSize16.toInt(), lineHeight: 1),
        backgroundColor: Colors.white,
        screenAdaptation: true,
        useDefaultBack: false,
        useBorderStyle: true,
        titleMargin: 0,
        border: TDNavBarItemBorder(
          width: 1,
          color: HexColor(HexColor.colorF9f9),
        ),
      ),
      body: SingleChildScrollView(
        padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
        child: Column(
          children: [
            Container(
              height: 80,
              padding: EdgeInsets.symmetric(horizontal: 20),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(5),
                color: Colors.white,
                border: Border.all(
                  width: 1,
                  color: HexColor(HexColor.colorF2f2),
                ),
              ),
              child: CustomPaint(
                painter: _MyCustomPaint(50),
                child: Row(
                  children: [
                    Expanded(
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          SvgPicture.network(
                            'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16391.svg',
                            width: 50,
                            height: 50,
                            fit: BoxFit.fill,
                          ).center(),
                          Container(
                            alignment: Alignment.centerLeft,
                            margin: EdgeInsets.only(left: 20),
                            child: TDText(
                              '产品库存',
                              style: StylesUtils.customTextStyle(
                                color: HexColor.color3333,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                    Expanded(
                      child: Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Container(
                            margin: EdgeInsets.only(left: 20),
                            alignment: Alignment.center,
                            child: SvgPicture.network(
                              'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16397.svg',
                              width: 50,
                              height: 50,
                              fit: BoxFit.fill,
                            ),
                          ),
                          Container(
                            alignment: Alignment.centerLeft,
                            margin: EdgeInsets.only(left: 20),
                            child: TDText(
                              '物料库存',
                              style: StylesUtils.customTextStyle(
                                color: HexColor.color3333,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 20),
              padding: EdgeInsets.only(bottom: 15),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(6),
                border: Border.all(
                  width: 1,
                  color: HexColor(HexColor.colorF2f2),
                ),
              ),
              child: Column(
                children: [
                  Container(
                    height: 50,
                    margin: EdgeInsets.only(bottom: 15),
                    padding: EdgeInsets.only(left: 15),
                    alignment: Alignment.centerLeft,
                    decoration: BoxDecoration(
                      border: Border(
                        bottom: BorderSide(
                          width: 1,
                          color: HexColor(HexColor.colorF2f2),
                        ),
                      ),
                    ),
                    child: TDText(
                      '快速入口',
                      style: StylesUtils.customTextStyle(
                        color: HexColor.color3333,
                        fontWeight: FontWeight.w700,
                      ),
                    ),
                  ),
                  StaggeredGrid.count(
                    crossAxisCount: 3,
                    mainAxisSpacing: 15,
                    children: [
                      Column(
                        children: [
                          Center(
                            child: SvgPicture.network(
                              'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16337.svg',
                              width: 50,
                              height: 48,
                              fit: BoxFit.fill,
                            ),
                          ),
                          Container(
                            alignment: Alignment.center,
                            margin: EdgeInsets.only(top: 8),
                            child: TDText(
                              '采购入库',
                              style: StylesUtils.customTextStyle(
                                color: HexColor.color3333,
                              ),
                            ),
                          ),
                        ],
                      ),
                      Column(
                        children: [
                          Center(
                            child: SvgPicture.network(
                              'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16333.svg',
                              width: 50,
                              height: 49,
                              fit: BoxFit.fill,
                            ),
                          ),
                          Container(
                            alignment: Alignment.center,
                            margin: EdgeInsets.only(top: 8),
                            child: TDText(
                              '退料入库',
                              style: StylesUtils.customTextStyle(
                                color: HexColor.color3333,
                              ),
                            ),
                          ),
                        ],
                      ),
                      Column(
                        children: [
                          Center(
                            child: SvgPicture.network(
                              'https://cdn8.axureshop.com/demo2023/2215319/images/%E8%B4%A8%E9%87%8F%E7%AE%A1%E7%90%86/u12635.svg',
                              width: 50,
                              height: 49,
                              fit: BoxFit.fill,
                            ),
                          ),
                          Container(
                            alignment: Alignment.center,
                            margin: EdgeInsets.only(top: 8),
                            child: TDText(
                              '产品入库',
                              style: StylesUtils.customTextStyle(
                                color: HexColor.color3333,
                              ),
                            ),
                          ),
                        ],
                      ),
                      Column(
                        children: [
                          Center(
                            child: SvgPicture.network(
                              'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16317.svg',
                              width: 50,
                              height: 49,
                              fit: BoxFit.fill,
                            ),
                          ),
                          Container(
                            alignment: Alignment.center,
                            margin: EdgeInsets.only(top: 8),
                            child: TDText(
                              '生产领料',
                              style: StylesUtils.customTextStyle(
                                color: HexColor.color3333,
                              ),
                            ),
                          ),
                        ],
                      ),
                      Column(
                        children: [
                          Center(
                            child: SvgPicture.network(
                              'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16321.svg',
                              width: 50,
                              height: 49,
                              fit: BoxFit.fill,
                            ),
                          ),
                          Container(
                            alignment: Alignment.center,
                            margin: EdgeInsets.only(top: 8),
                            child: TDText(
                              '销售出库',
                              style: StylesUtils.customTextStyle(
                                color: HexColor.color3333,
                              ),
                            ),
                          ),
                        ],
                      ),
                      Column(
                        children: [
                          Center(
                            child: SvgPicture.network(
                              'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16325.svg',
                              width: 50,
                              height: 49,
                              fit: BoxFit.fill,
                            ),
                          ),
                          Container(
                            alignment: Alignment.center,
                            margin: EdgeInsets.only(top: 8),
                            child: TDText(
                              '供货商退款',
                              style: StylesUtils.customTextStyle(
                                color: HexColor.color3333,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 20),
              decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(6),
                border: Border.all(
                  width: 1,
                  color: HexColor(HexColor.colorF2f2),
                ),
              ),
              child: TDCellGroup(
                cells: [
                  TDCell(
                    titleWidget: TDText(
                      '出入库历史',
                      style: StylesUtils.customTextStyle(
                        fontWeight: FontWeight.w700,
                        color: HexColor.color3333,
                      ),
                    ),
                    showBottomBorder: true,
                  ),
                  TDCell(
                    arrow: true,
                    showBottomBorder: true,
                    title: '采购入库历史',
                    imageWidget: SvgPicture.network(
                      'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16360.svg',
                      width: 20,
                      height: 24,
                      fit: BoxFit.fill,
                    ),
                    imageCircle: 0,
                  ),
                  TDCell(
                    arrow: true,
                    showBottomBorder: true,
                    title: '退料入库历史',
                    imageWidget: SvgPicture.network(
                      'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16360.svg',
                      width: 20,
                      height: 24,
                      fit: BoxFit.fill,
                    ),
                    imageCircle: 0,
                  ),
                  TDCell(
                    arrow: true,
                    showBottomBorder: true,
                    title: '产品入库历史',
                    imageWidget: SvgPicture.network(
                      'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16372.svg',
                      width: 20,
                      height: 24,
                      fit: BoxFit.fill,
                    ),
                    imageCircle: 0,
                  ),
                  TDCell(
                    arrow: true,
                    showBottomBorder: true,
                    title: '生产领料历史',
                    imageWidget: SvgPicture.network(
                      'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16360.svg',
                      width: 20,
                      height: 24,
                      fit: BoxFit.fill,
                    ),
                    imageCircle: 0,
                  ),
                  TDCell(
                    arrow: true,
                    showBottomBorder: true,
                    title: '销售出库历史',
                    imageWidget: SvgPicture.network(
                      'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16378.svg',
                      width: 20,
                      height: 24,
                      fit: BoxFit.fill,
                    ),
                    imageCircle: 0,
                  ),
                  TDCell(
                    arrow: true,
                    showBottomBorder: false,
                    title: '供应商退货历史',
                    imageWidget: SvgPicture.network(
                      'https://cdn8.axureshop.com/demo2023/2215319/images/%E5%87%BA%E5%85%A5%E5%BA%93/u16375.svg',
                      width: 20,
                      height: 24,
                      fit: BoxFit.fill,
                    ),
                    imageCircle: 0,
                  ),
                ],
                style: TDCellStyle.cellStyle(context),
              ),
            )
          ],
        ),
      ),
    );
  }
}

class _MyCustomPaint extends CustomPainter {
  final int len;
  _MyCustomPaint(this.len);

  @override
  void paint(Canvas canvas, Size size) {
    Offset start = Offset(size.width / 2, (size.height - len) / 2);
    Offset end = Offset(size.width / 2, (size.height - len) / 2 + len);
    Paint paint = Paint()
      ..color = HexColor(HexColor.colorF2f2)
      ..style = PaintingStyle.stroke
      ..strokeWidth = 1;
    canvas.drawLine(start, end, paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return this != oldDelegate;
  }
}
